package com.etone.smartAudit.task;

import com.etone.smartAudit.service.AuditExceptionService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: sovy
 * @date: 2020/8/10
 * @description:
 */
@Component
@Log4j2
public class AuditExceptionTask {

    @Value("${audit.task.enable:false}")
    private Boolean enableTask;

    @Autowired
    private AuditExceptionService auditExceptionService;

    @Scheduled(cron = "0 30 0 * * ?")
    public void clean() {
        if (enableTask) {
            log.info("===========================开始生成审计文件===========================");
            auditExceptionService.createLocalFile(false);
            log.info("===========================生成审计文件结束===========================");
        }
    }

    @Scheduled(cron = "0 30 1 1 * ? ")
    public void countReport() {
        log.info("===========================开始统计异常审计点===========================");
        auditExceptionService.auditExceptionCountReport();
        log.info("===========================结束统计异常审计点===========================");
    }

}
